import {request} from '@/plugins/axios'
import ApiPath from '@/utils/api_paths'

export function list(query) {
    return request({
        url: ApiPath.dept,
        method: 'get',
        params: query
    })
}

export function listAll(query) {
    return request({
        url: ApiPath.dept + '/list/all',
        method: 'get',
        params: query
    })
}

export function add(data) {
    if(!data.parentId) data.parentId = 0;
    return request({
        url: ApiPath.dept,
        method: 'post',
        data
    })
}

export function del(id) {
    return request({
        url: ApiPath.dept + '/' + id,
        method: 'delete'
    })
}

export function update(data) {
    return request({
        url: ApiPath.dept + '/' + data.deptId,
        method: 'put',
        data
    })
}

export function get(id) {
    return request({
        url: ApiPath.dept + '/' + id,
        method: 'get'
    })
}

